#include <iostream>

using namespace std;

const int N = 1e6 + 10;

int A[N], B[N];
int n, m;

int main(void)
{
    scanf("%d%d", &n, &m);
    for (int i = 0; i < n; i++)
        scanf("%d", &A[i]);
    for (int i = 0; i < m; i++)
        scanf("%d", &B[i]);

    for (int i = 0, j = 0;; j++)
    {
        if (i == n)
        {
            printf("Yes\n");
            return 0;
        }
        else if (j == m)
            break;
        else if (A[i] == B[j])
            i++;
    }
    printf("No\n");
    return 0;
}